package com.heima.feign.config;

import com.heima.feign.client.ArticleFetignClient;
import com.heima.model.article.dto.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import org.springframework.cloud.openfeign.FallbackFactory;


/**
 * feign接口降级配置
 */
public class ArticleClientFallbackFactory implements FallbackFactory <ArticleFetignClient>{
    @Override
    public ArticleFetignClient create(Throwable cause) {
        return new ArticleFetignClient() {
            @Override
            public ResponseResult<String> saveArticle(ArticleDto dto) {
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
            }
        };
    }
}
